package string;

public class Example2 {

	/**输出在一个字符串中，指定字符串出现的次数
	 * @param args
	 */
	public static void main(String[] args) {
		
		String s = "sunjavafdsjavaoppgjavaljgjavaiijava";
		String sToFind = "java";
				
		int count = 0;
		int index = -1; //假设刚开始没找到，就是 -1
			
		while((index = s.indexOf(sToFind)) != -1){
			s = s.substring(index + sToFind.length());
			System.out.println(s);
			count ++;
		}
		
		System.out.println(count);
	}	

}
